package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the PURCHASE database table.
 * 
 */
@Entity
@NamedQuery(name="Purchase.findAll", query="SELECT p FROM Purchase p")
public class Purchase implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="PURCHASE_PURCHASEID_GENERATOR", sequenceName="SEQ",initialValue=1,allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PURCHASE_PURCHASEID_GENERATOR")
	@Column(name="PURCHASE_ID")
	private long purchaseId;

	@Temporal(TemporalType.DATE)
	@Column(name="ARRIVE_DATE")
	private Date arriveDate;

	private BigDecimal bill;

	@Column(name="CLASSIFY_ID")
	private BigDecimal classifyId;

	@Column(name="\"MONEY\"")
	private BigDecimal money;

	@Temporal(TemporalType.DATE)
	private Date orderdate;

	private BigDecimal paid;

	@Column(name="PURCHASE_NUM")
	private String purchaseNum;

	private String remarks;

	private String status;

	@Column(name="STOCK_ID")
	private BigDecimal stockId;

	private String theme;

	//bi-directional many-to-one association to Product
	@OneToMany(mappedBy="purchase")
	@JSONField(serialize=false)
	private List<Product> products;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="USER_ID")
	private User user;

	public Purchase() {
	}

	public long getPurchaseId() {
		return this.purchaseId;
	}

	public void setPurchaseId(long purchaseId) {
		this.purchaseId = purchaseId;
	}

	public Date getArriveDate() {
		return this.arriveDate;
	}

	public void setArriveDate(Date arriveDate) {
		this.arriveDate = arriveDate;
	}

	public BigDecimal getBill() {
		return this.bill;
	}

	public void setBill(BigDecimal bill) {
		this.bill = bill;
	}

	public BigDecimal getClassifyId() {
		return this.classifyId;
	}

	public void setClassifyId(BigDecimal classifyId) {
		this.classifyId = classifyId;
	}

	public BigDecimal getMoney() {
		return this.money;
	}

	public void setMoney(BigDecimal money) {
		this.money = money;
	}

	public Date getOrderdate() {
		return this.orderdate;
	}

	public void setOrderdate(Date orderdate) {
		this.orderdate = orderdate;
	}

	public BigDecimal getPaid() {
		return this.paid;
	}

	public void setPaid(BigDecimal paid) {
		this.paid = paid;
	}

	public String getPurchaseNum() {
		return this.purchaseNum;
	}

	public void setPurchaseNum(String purchaseNum) {
		this.purchaseNum = purchaseNum;
	}

	public String getRemarks() {
		return this.remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public BigDecimal getStockId() {
		return this.stockId;
	}

	public void setStockId(BigDecimal stockId) {
		this.stockId = stockId;
	}

	public String getTheme() {
		return this.theme;
	}

	public void setTheme(String theme) {
		this.theme = theme;
	}

	public List<Product> getProducts() {
		return this.products;
	}

	public void setProducts(List<Product> products) {
		this.products = products;
	}

	public Product addProduct(Product product) {
		getProducts().add(product);
		product.setPurchase(this);

		return product;
	}

	public Product removeProduct(Product product) {
		getProducts().remove(product);
		product.setPurchase(null);

		return product;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

}